<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<!-- author = Wink Hosting (www.winkhosting.com) -->

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
  <meta name="generator" content=
  "HTML Tidy for Linux (vers 1 September 2005), see www.w3.org" />
  <meta http-equiv="content-type" content=
  "text/html; charset=us-ascii" />
  <meta name="description" content="description" />
  <meta name="keywords" content="keywords" />
  <meta name="author" content="author" />
  <link rel="shortcut icon" type="image/x-icon" href=
  "http://awk.googlecode.com/svn/branches/tiny/img/favicon.ico" />
  <title>TinyMining : quartiles.awk</title>
<style type="text/css">
/*<![CDATA[*/
/* 
CSS Document 
Wink Hosting (www.winkhosting.com)
Designed By Alexis Corredor
alexis.corredor@gmail.com
*/
body {
margin-top: 0px;
margin-left: 0px;
margin-right: 0px;
margin-bottom: 0px;
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 11px; 
text-align: left;
align: left;
}
p.left {text-align: left}
/*HEADER*/
#header{
width: 800px;
position:relative; 
height: 162px;
background-image:url(http://awk.googlecode.com/svn/branches/tiny/img/header.jpg);
background-repeat:no-repeat;
}
/*COMPANY NAME IN HEADER*/
#companyname {
position:absolute;
font-family: Verdana, Arial, Helvetica, sans-serif;
color: #FFFFFF;
font-size: 30px;
font-weight: bold;
margin-top:30px;
margin-left:40px;
left: 0px;
top: 0px;
}
#companyname a{
font-family: Verdana, Arial, Helvetica, sans-serif;
color:#FFFFFF;
text-decoration:none;
}
#companyname a:hover{
text-decoration:underline;
}
/*MENU IN HEADER*/
#menu{
position:absolute;
bottom: 20px;
right: 30px;
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 10px;
font-weight: bold;
}
#menu a{
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 10px;
font-weight: bold;
color:#333333;
text-decoration:none;
}
#menu a:hover{
text-decoration:underline;
}
/*LEFT PANEL (News, Links, etc.)*/
#leftpanel{
float:left;
width:200px;
}
/*CONTENT*/
#content{
width: 800px;
}
#contenttext{
text-align: left;
float: right;
width: 580px;
}
/*FOOTER*/
.footer{
width: 779px;
height: 32px;
background-image:url(http://awk.googlecode.com/svn/branches/tiny/img/bg_footer.gif);
background-repeat:no-repeat;
clear:both;
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 10px;
font-weight: bold;
color:#FFFFFF;
}
/*FOOTER LINKS*/
.footer a{
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 10px;
font-weight: bold;
color:#FFFFFF;
text-decoration:none;
}
.footer a:hover{
text-decoration:underline;
}
/*TABLE*/
.table_top{
width: 204px; 
height: 27px;
background-image:url(http://awk.googlecode.com/svn/branches/tiny/img/table_top.jpg);
background-repeat:no-repeat;
}
.table_content{
width: 204px;
background-image:url(http://awk.googlecode.com/svn/branches/tiny/img/table_content.jpg);
background-repeat:repeat-y;
}
.table_text{
margin-left:15px;
margin-right:15px;
text-align:justify;
}
.table_bottom{
width: 204px; height: 23px;
}
/*TEXT STYLES*/
.news_date {    
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 10px;
font-weight: bold;
color: #0099CC;
}
.body_text {    
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 11px; align: left;
}
.news_more {    
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 10px;
color: #FF9900;
font-weight: bold;
}
.news_text {    font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 10px;
}
.subtitle_gray {        
font-family:Verdana, Arial, Helvetica, sans-serif;      
font-weight: bold;
font-size: 14px;
color: #CCCCCC;
}
h1 {
margin-top: 0px; padding-top: 0px; font-family: Verdana, Arial, Helvetica, sans-serif; font-weight: bold; font-size: 26px; color: #7DA5E0; 
}
.title_blue {
font-family: Verdana, Arial, Helvetica, sans-serif; font-weight: bold; font-size: 26px; color: #7DA5E0; 
}
.title_panel {  font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 12px;
font-weight: bold;
}
pre {
margin-left: 20px;
padding: 1em;
border: 1px dashed #2f6fab;
color: DarkBlue;
background-color: #f9f9f9;
line-height: 1.1em;
}
#title p {
float: right;
text-align: right;
text-width: 750px;
color: white; 
margin: 0 20px 0px 0; 
line-height: 1.2em;
padding-top: 5px;
padding-bottom: 5px;
padding-top: 20px;
}
p.tags {
font-size: x-small;
margin-top: 0px;
margin-botton: 0px;
text-align: right;
color: #AAA;
}
h1 h2 h3 h4 h5 h6 h7 { color:  #7DA5E0; }
h2 { border-top: 1px solid #7DA5E0; } 
/*]]>*/
</style>
</head>

<body>
  <div id="page" align="center">
    <div id="header">
     <div id="title">google-search  </div> 
      <div id="companyname" align="left">
        quartiles.awk
      </div>

      <div align="right" class="links_menu" id="menu">
	    mennu
      </div>
    </div><br />

    <div id="content">
      <div id="leftpanel">

        <div class="table_top">
          <div align="center">
            <span class="title_panel">News</span>
          </div>
        </div>

        <div class="table_content">
          <div class="table_text">

             news
          </div>
        </div>
    
        <div class="table_bottom">
          <img src="http://awk.googlecode.com/svn/branches/tiny/img/table_bottom.jpg"
          width="204" height="23" border="0" alt="" />
        </div>
        <p/>

        <div class="table_top">
          <div align="center">
            <span class="title_panel">News</span>
          </div>
        </div>

        <div class="table_content">
          <div class="table_text">
				Links
          </div>
        </div>
    
        <div class="table_bottom">
          <img src="http://awk.googlecode.com/svn/branches/tiny/img/table_bottom.jpg"
          width="204" height="23" border="0" alt="" />
        </div>
        <p/>
        <div class="table_top">
          <span class="title_panel">Links</span>
        </div>

        <div class="table_content">
          <div class="table_text">
			SEE also
          </div>
        </div>

        <div class="table_bottom">
          <img src="http://awk.googlecode.com/svn/branches/tiny/img/table_bottom.jpg"
          width="204" height="23" border="0" alt="" />
        </div>
        <p/>

      </div>

      <div id="contenttext">
         <img src="http://awk.googlecode.com/svn/branches/tiny/img/babel.jpg" align=right width=200  
		        style="margin: 3px; padding: 1px; border: 1px solid #CCC;">


<h1> @include "lib.awk"
 @include "quartile.awk"
 @include "mwu.awk"
 BEGIN { OFS=FS="," }
 /#/   { next }
 /audiology/       { gsub(/[ \t]*/,"")
		 Source=$1
         Key=$2
		 for(I=3;I<NF;I++) Key= Key OFS $I
         Db[Source][Key][NR] = $NF
         Db["_"   ][Key][NR] = $NF
        }
 END   {Com="sort -t, -n -k 5"
        for(Source in Db)  {
			print "# " Source
			array(Median)
			for(Key in Db[Source]) {
					asort(Db[Source][Key],All)
					tmp=median(All) + rand()/10000
			       	Median[Key] = tmp
					Index[tmp] = Key
                    Output[Key]= quartile(All,"Prefix="Key) 
                    print  quartile(All,"Prefix="Key)  | Com
            }
			close(Com)
	        asort(Median,Sorted)
			N=a1b2c4d8(Sorted,Splits)
			Rank[1]=1
            if(N>0) {
				for(I=1;I<=Splits[1];I++) A[I]=value2median(Sorted[I])
            	for(I=1;I<=Splits[1];I++) Label[I] = Rank[1]
            }
            if(N>1) {
				for(J=I;J<=Splits[2];J++) B[J]=value2median(Sorted[J])
				Rank[2] = Rank[1] + mwu(A,B,0,criticalValue(95))
				for(J=I;J<=Splits[2];J++) Label[J]=Rank[2]
			}
            if(N>2) {
				for(K=J;K<=Splits[3];K++) C[K]=value2median(Sorted[K])
				Rank[3] = Rank[2] + mwu(B,C,0,criticalValue(95))
				for(K=J;K<=Splits[3];K++) Label[K]=Rank[3]
			}
            if(N>3) {
				for(L=K;L<=Splits[4];L++) D[L]=value2median(Sorted[L])
				Rank[4] = Rank[3] + mwu(C,D,0,criticalValue(95))
				for(L=K;L<=Splits[4];L++) Label[L] =Rank[4]
			}	
            for(I=1;I<=length(Sorted);I++)
				print Label[I] "," Output[Index[Sorted[I]]]
       }}
      
  function value2median(x) {
	return Median[Index[x]]
  } 
  function a1b2c4d8(l,splits,     max,a,b,c,d) {
       max= length(l) 
	   a = int(max/15)
       if (a<1) a = 1
	   #------------------
	   if (a>max) a=max;
       while (a <max && (l[a] < l[a+1] - 0.001)) a++;
	   splits[1]=a;
	   if (a==max) return 1
	   #------------------
	   b = a * 2
	   if (b > max) b=max
       while (b < max && (l[b] < l[b+1] - 0.001)) b++
	   splits[2]=b
	   if (b==max) return 2
	   #------------------
       c= b * 2
	   if (c > max) c=max
       while (c < max && (l[c] < l[c+1] - 0.001)) c++
	   splits[3]=c
	   if (c==max) return 3
	   #------------------
       splits[4]=max
       return 4
 }</h1>

        <p>&nbsp;</p>
      </div><br />
      <br />

      <div class="footer">
			footer
      </div>
    </div>
  </div>
</body>
</html>


